Skip to content

feat(core): finalize session event lifecycle#35272

Open
kitlangton wants to merge 8 commits into
v2from
event-fragments
Open

feat(core): finalize session event lifecycle#35272
kitlangton wants to merge 8 commits into
v2from
event-fragments

Conversation

@kitlangton

@kitlangton kitlangton commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Closes #35019, #35016, and #35020.

What Changed

  • Removes provider block IDs while giving text/reasoning events stable Session-assigned ordinals.
  • Flattens tool/provider continuation state at the Session boundary.
  • Adds durable execution started, succeeded, failed, and interrupted events.
  • Adds bounded pre-output retries while reusing one projected Assistant.
  • Uses one forward-compatible public error envelope: { type: string, message: string }.
  • Guarantees every tool settles before its owning step ends or fails.
  • Streams compaction summaries and updates checkpoint headings for resumption.
  • Normalizes equivalent OpenAPI components before SDK generation, removing suffixed duplicate Session event families.

Review Map

  1. Contracts: packages/schema/src/session-{event,message,error}.ts
  2. Execution and ordering: packages/core/src/session/{execution,runner}
  3. Projection and consumers: packages/core/src/session/projector.ts, packages/tui, and V2-backed run compatibility
  4. SDK normalization: packages/sdk/js/script/build.ts and generated V2 surfaces

Why The Diff Is Large

This deliberately collapses three formerly stacked PRs into one so the incompatible Session contract runs one reset instead of several.

The addition count is dominated by generated and test code:

  • About 2,680 additions are generated client/SDK output; the same generated files remove about 3,400 lines by eliminating duplicate suffixed Session event families.
  • About 1,650 additions are focused regression tests.
  • About 1,300 additions are implementation and generator logic across Core, Schema, LLM, TUI, and run compatibility.
  • The remainder is the migration and V2 documentation.

Compatibility

SessionError.type is intentionally open. New classifications do not require event versions or database resets, and older decoders ignore future optional fields. Rich public details are deferred to #35325.

Text and reasoning events carry a kind-specific ordinal. Hydrated projections derive the same ordinal from content order, so buffered live events reconcile to the correct fragment without exposing provider IDs.

One migration, 20260703200000_reset_v2_session_events, clears experimental V2 events, sequences, projected messages, and admitted inputs. Sessions and unrelated data remain intact.

Final Correctness Pass

The simplify/correctness review found and fixed two real issues:

  • Buffered fragment starts could advance a synthetic ordinal after hydration and misroute or duplicate a delta. Events now carry stable ordinals, with a resize regression test.
  • Generated SDK output still exposed suffixed duplicate Session event families. Components now normalize and deduplicate before generation, with a broad duplicate guard.

A follow-up review of those fixes passed with no findings.

Verification

  • 117 focused Core session/projector/permission tests
  • 17 focused Core tool tests
  • 15 focused Schema tests
  • 30 focused run transport/updater tests, 3 skipped
  • 33 focused TUI tests
  • All package and full-repository typechecks passed
  • Client and legacy SDK generation reproduced cleanly twice
  • File-scoped oxlint reported no errors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant